<template>
  <a-form :model="formState" ref="formDataRef" name="basic" :label-col="{ style: 'width:90px' }" :wrapper-col="{ style: 'calc(100% - 90px)' }" autocomplete="off">
    <a-form-item label="驳回类型" name="refuseType" :rules="[{ required: true, message: '请选择驳回类型!' }]">
      <a-select v-model:value="formState.refuseType" placeholder="请选择">
        <a-select-option v-for="(item, index) in dataDict['REJECT_TYPE']" :key="index" :value="item.code">{{ item.name }}</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="驳回原因" name="refuseReason" :rules="[{ required: true, message: '请填写驳回原因!' }]">
      <a-textarea v-model:value="formState.refuseReason" placeholder="请输入" show-count :maxlength="300" />
    </a-form-item>
    <a-form-item :wrapper-col="{ offset: 8, span: 16 }" class="submit-btn-form-item">
      <a-button :loading="loading" type="danger" style="margin-right: 16px" @click="submitHandle(2)">驳回并审批下一个</a-button>
      <a-button :loading="loading" type="danger" style="margin-right: 16px" @click="submitHandle(1)">驳回</a-button>
      <a-button @click="resetHandle">取消</a-button>
    </a-form-item>
  </a-form>
</template>

<script lang="ts" setup>
import { toRefs, watch } from "vue";
import CommonHook from "@/hook/commonHook";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
const props = withDefaults(
  defineProps<{
    visible: boolean;
    passData: Base.GeneraDataType;
  }>(),
  {}
);
const emit = defineEmits<{
  (e: "update:visible", blo: boolean): void;
  (e: "submit", type: number): void; // 1 驳回  2 驳回并下一个
}>();
const { dataDict } = CommonHook();
const { visible, passData } = toRefs(props);
const { formDataRef, formState, loading } = InitHook();
const { submitHandle, resetFields, resetHandle } = OperationHook({ formDataRef, formState, passData, emit, loading });
watch(
  () => visible.value,
  (v: boolean) => {
    if (!v) {
      resetFields();
      formDataRef.value.clearValidate();
    }
  }
);
</script>
<style lang="stylus" scoped>
:deep(.ant-input-number){
    width: 100%;
}
</style>
